package com.lunar.controller;


import com.lunar.entity.Companyinfo;
import com.lunar.service.CompAnyInfoService;
import com.lunar.service.TelVisitService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class CompanyinfoController {

    @Autowired
    private CompAnyInfoService compAnyInfoService;

    @Autowired
    private TelVisitService telVisitService;

    @RequestMapping("/getAll")
    public List<Companyinfo> getAll(){
        return  compAnyInfoService.getAll();
    }

    @RequestMapping("/addComp")
    public int addComp(Companyinfo companyinfo){
        return compAnyInfoService.addCompAnyInfo(companyinfo);
    }

    @GetMapping("/deleteComp")
    public int deleteComp(int cid){
        System.out.println(cid);
        int count = telVisitService.deleteTel(cid);
        System.out.println(count);
        return compAnyInfoService.deleteComp(cid);
    }

    @GetMapping("/selectByName")
    public List<Companyinfo> selectByName(String compName, String ownerName){
        return compAnyInfoService.selectByName(compName,ownerName);
    }
}
